#include "TypeTable.h"

#include "Type.h"
#include "ScriptRuntime/Type/GSharpClass.h"

CTypeTable::CTypeTable()
{
}

void CTypeTable::AddType(CType *InType, STypeID InTypeID)
{
    assert(InType && InTypeID.IsValid());

    Types.Add(InTypeID, InType);

    if (InTypeID.IsScriptType())
    {
        ScriptTypes.Add(InType);
    }
    else
    {
        NativeTypes.Add(InType);
    }
}

CType *CTypeTable::FindType(STypeID InTypeID)
{
    assert(InTypeID.IsValid());
    
    auto Type = Types.Find(InTypeID);
    if (Type)
    {
        return *Type;
    }
    else
    {
        return nullptr;
    }
}

TVector<CType *> CTypeTable::GetAllNativeTypes() const
{
    return NativeTypes;
}

TVector<CType *> CTypeTable::GetAllScriptTypes() const
{
    return ScriptTypes;
}
